home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / VB Source 20626652001.psc / frmPrint.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-06-05  |  12.6 KB  |  389 lines

  1. VERSION 5.00
  2. Begin VB.Form frmPrint 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Print Source Code By Santiago M
  5. ndez"
  6.    ClientHeight    =   5430
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   4845
  10.    Icon            =   "frmPrint.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   5430
  15.    ScaleWidth      =   4845
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   3  'Windows Default
  18.    Begin VB.TextBox Text 
  19.       Height          =   285
  20.       Index           =   3
  21.       Left            =   2640
  22.       TabIndex        =   7
  23.       Text            =   "Text"
  24.       ToolTipText     =   "Margin in cm."
  25.       Top             =   4320
  26.       Width           =   615
  27.    End
  28.    Begin VB.TextBox Text 
  29.       Height          =   285
  30.       Index           =   2
  31.       Left            =   3240
  32.       TabIndex        =   6
  33.       Text            =   "Text"
  34.       ToolTipText     =   "Margin in cm."
  35.       Top             =   3240
  36.       Width           =   615
  37.    End
  38.    Begin VB.TextBox Text 
  39.       Height          =   285
  40.       Index           =   1
  41.       Left            =   600
  42.       TabIndex        =   5
  43.       Text            =   "Text"
  44.       ToolTipText     =   "Margin in cm."
  45.       Top             =   3720
  46.       Width           =   615
  47.    End
  48.    Begin VB.TextBox Text 
  49.       Height          =   285
  50.       Index           =   0
  51.       Left            =   1080
  52.       TabIndex        =   4
  53.       Text            =   "Text"
  54.       ToolTipText     =   "Margin in cm."
  55.       Top             =   2640
  56.       Width           =   615
  57.    End
  58.    Begin VB.ComboBox Combo 
  59.       Height          =   315
  60.       ItemData        =   "frmPrint.frx":000C
  61.       Left            =   1560
  62.       List            =   "frmPrint.frx":0020
  63.       Style           =   2  'Dropdown List
  64.       TabIndex        =   3
  65.       Top             =   2040
  66.       Width           =   2055
  67.    End
  68.    Begin VB.CommandButton CmdOK 
  69.       Caption         =   "&OK"
  70.       Default         =   -1  'True
  71.       Height          =   375
  72.       Left            =   2040
  73.       TabIndex        =   8
  74.       Top             =   4920
  75.       Width           =   1095
  76.    End
  77.    Begin VB.CommandButton CmdCancel 
  78.       Caption         =   "&Cancel"
  79.       Height          =   375
  80.       Left            =   3360
  81.       TabIndex        =   9
  82.       Top             =   4920
  83.       Width           =   1095
  84.    End
  85.    Begin VB.Frame Frame3 
  86.       Caption         =   "Options"
  87.       Height          =   1095
  88.       Left            =   2400
  89.       TabIndex        =   14
  90.       Top             =   720
  91.       Width           =   2295
  92.       Begin VB.CheckBox Check1 
  93.          Caption         =   "Print Index page"
  94.          Height          =   195
  95.          Left            =   360
  96.          TabIndex        =   2
  97.          Top             =   360
  98.          Width           =   1500
  99.       End
  100.    End
  101.    Begin VB.Frame Frame2 
  102.       Caption         =   "Range :"
  103.       Height          =   1095
  104.       Left            =   120
  105.       TabIndex        =   13
  106.       Top             =   720
  107.       Width           =   1935
  108.       Begin VB.OptionButton OptionB 
  109.          Caption         =   "Selection"
  110.          Height          =   255
  111.          Index           =   0
  112.          Left            =   120
  113.          TabIndex        =   0
  114.          Top             =   360
  115.          Width           =   1335
  116.       End
  117.       Begin VB.OptionButton OptionB 
  118.          Caption         =   "Current Module"
  119.          Height          =   255
  120.          Index           =   1
  121.          Left            =   120
  122.          TabIndex        =   1
  123.          Top             =   720
  124.          Value           =   -1  'True
  125.          Width           =   1695
  126.       End
  127.    End
  128.    Begin VB.CommandButton CmdSetup 
  129.       Caption         =   "Setup..."
  130.       Height          =   375
  131.       Left            =   3600
  132.       TabIndex        =   10
  133.       Top             =   120
  134.       Width           =   1095
  135.    End
  136.    Begin VB.Label Label7 
  137.       Alignment       =   2  'Center
  138.       Appearance      =   0  'Flat
  139.       BackColor       =   &H80000004&
  140.       BackStyle       =   0  'Transparent
  141.       BorderStyle     =   1  'Fixed Single
  142.       Caption         =   "Note: Margins are set from printer print area. Not from paper borders."
  143.       BeginProperty Font 
  144.          Name            =   "Arial"
  145.          Size            =   6.75
  146.          Charset         =   0
  147.          Weight          =   400
  148.          Underline       =   0   'False
  149.          Italic          =   0   'False
  150.          Strikethrough   =   0   'False
  151.       EndProperty
  152.       ForeColor       =   &H80000008&
  153.       Height          =   975
  154.       Left            =   3480
  155.       TabIndex        =   20
  156.       ToolTipText     =   "Note: Margins are set from printer print area. Not from paper borders."
  157.       Top             =   3720
  158.       Width           =   1215
  159.    End
  160.    Begin VB.Line Line3 
  161.       BorderColor     =   &H80000005&
  162.       X1              =   120
  163.       X2              =   4680
  164.       Y1              =   1935
  165.       Y2              =   1935
  166.    End
  167.    Begin VB.Line Line4 
  168.       BorderColor     =   &H80000003&
  169.       X1              =   120
  170.       X2              =   4680
  171.       Y1              =   1920
  172.       Y2              =   1920
  173.    End
  174.    Begin VB.Image Image1 
  175.       Height          =   1290
  176.       Left            =   1440
  177.       Picture         =   "frmPrint.frx":003E
  178.       Stretch         =   -1  'True
  179.       Top             =   3000
  180.       Width           =   1020
  181.    End
  182.    Begin VB.Label Label6 
  183.       Caption         =   "Bottom:"
  184.       Height          =   255
  185.       Left            =   1920
  186.       TabIndex        =   19
  187.       Top             =   4335
  188.       Width           =   615
  189.    End
  190.    Begin VB.Label Label5 
  191.       Caption         =   "Right :"
  192.       Height          =   255
  193.       Left            =   2640
  194.       TabIndex        =   18
  195.       Top             =   3255
  196.       Width           =   495
  197.    End
  198.    Begin VB.Label Label4 
  199.       Caption         =   "Left :"
  200.       Height          =   255
  201.       Left            =   120
  202.       TabIndex        =   17
  203.       Top             =   3735
  204.       Width           =   615
  205.    End
  206.    Begin VB.Label Label3 
  207.       Caption         =   "Top:"
  208.       Height          =   255
  209.       Left            =   600
  210.       TabIndex        =   16
  211.       Top             =   2655
  212.       Width           =   615
  213.    End
  214.    Begin VB.Line Line6 
  215.       BorderColor     =   &H80000003&
  216.       X1              =   120
  217.       X2              =   4680
  218.       Y1              =   2520
  219.       Y2              =   2520
  220.    End
  221.    Begin VB.Line Line5 
  222.       BorderColor     =   &H80000005&
  223.       X1              =   120
  224.       X2              =   4680
  225.       Y1              =   2535
  226.       Y2              =   2535
  227.    End
  228.    Begin VB.Label Label2 
  229.       Caption         =   "Print Quality :"
  230.       Height          =   255
  231.       Left            =   240
  232.       TabIndex        =   15
  233.       Top             =   2070
  234.       Width           =   1215
  235.    End
  236.    Begin VB.Line Line2 
  237.       BorderColor     =   &H80000005&
  238.       X1              =   120
  239.       X2              =   4680
  240.       Y1              =   4815
  241.       Y2              =   4815
  242.    End
  243.    Begin VB.Line Line1 
  244.       BorderColor     =   &H80000003&
  245.       X1              =   120
  246.       X2              =   4680
  247.       Y1              =   4800
  248.       Y2              =   4800
  249.    End
  250.    Begin VB.Label LblPrinter 
  251.       Caption         =   "Label2"
  252.       Height          =   255
  253.       Left            =   1080
  254.       TabIndex        =   12
  255.       Top             =   240
  256.       Width           =   2415
  257.    End
  258.    Begin VB.Label Label1 
  259.       Caption         =   "Printer : "
  260.       Height          =   255
  261.       Left            =   240
  262.       TabIndex        =   11
  263.       Top             =   240
  264.       Width           =   735
  265.    End
  266. Attribute VB_Name = "frmPrint"
  267. Attribute VB_GlobalNameSpace = False
  268. Attribute VB_Creatable = False
  269. Attribute VB_PredeclaredId = True
  270. Attribute VB_Exposed = False
  271. Option Explicit
  272. ' Module Name:  frmPrint.frm
  273. ' Author:       Santiago A. M
  274. ndez  (Guatemala, C.A.)
  275. ' email:        Santiago@InternetDeTelgua.com.gt
  276. ' Date:         23-Abr-01
  277. ' Description:  The purpose of this form is to bring the user the choice to define printer settings,
  278. '               print an index page, print the entire module or to print only the selected text
  279. Public Sub Display()
  280.     Dim StartLine&, EndLine&, StartCol&, EndCol&
  281.     'GET RANGE OF LINES SELECTED IN WINDOW
  282.     VBI.ActiveCodePane.GetSelection StartLine, StartCol, EndLine, EndCol
  283.     LblPrinter.Caption = Printer.DeviceName
  284.     'ENABLE OR DISABLE Range "Selection" OPTION BUTTON
  285.     OptionB(0).Enabled = StartCol <> EndCol Or StartLine <> EndLine
  286.     Me.Show vbModal
  287. End Sub
  288. Private Sub CmdCancel_Click()
  289.     Unload Me
  290. End Sub
  291. Private Sub CmdOK_Click()
  292.     Dim PrintCode As New PrintSource
  293.     MousePointer = vbHourglass
  294.     Screen.MousePointer = vbHourglass
  295.     'SET PRINT QUALITY & MARGINS
  296.     Printer.PrintQuality = Combo.ItemData(Combo.ListIndex)
  297.     PrintCode.PrinterTop = Text(0)
  298.     PrintCode.PrinterLeft = Text(1)
  299.     PrintCode.PrinterRigth = Text(2)
  300.     PrintCode.PrinterBottom = Text(3)
  301.     If OptionB(0) Then
  302.         'PRINT SELECTION
  303.         PrintCode.PrintSourceCode True, Check1.Value = vbChecked
  304.     Else
  305.         'PRINT ENTIRE MODULE
  306.         PrintCode.PrintSourceCode False, Check1.Value = vbChecked
  307.     End If
  308.     MousePointer = vbDefault
  309.     'MARGINS
  310.     SaveSetting Me.Name, "Settings", "PrintTop", Text(0)
  311.     SaveSetting Me.Name, "Settings", "PrintLeft", Text(1)
  312.     SaveSetting Me.Name, "Settings", "PrintRight", Text(2)
  313.     SaveSetting Me.Name, "Settings", "PrintBottom", Text(3)
  314.     'PRINT QUALITY
  315.     SaveSetting Me.Name, "Settings", "PrintQuality", Combo.ItemData(Combo.ListIndex)
  316.     Screen.MousePointer = vbDefault
  317.     Unload Me
  318. End Sub
  319. Private Sub CmdSetup_Click()
  320.     If ShowPrinter(Me, PD_PRINTSETUP) Then UpdateCombo Printer.PrintQuality
  321. End Sub
  322. Private Sub UpdateCombo(PQuality As Long)
  323.     Dim i%
  324.     If PQuality <> Combo.ItemData(Combo.ListIndex) Then
  325.         Select Case Printer.PrintQuality
  326.             Case vbPRPQDraft
  327.                 Combo.ListIndex = 0
  328.             Case vbPRPQLow
  329.                 Combo.ListIndex = 1
  330.             Case vbPRPQMedium
  331.                 Combo.ListIndex = 2
  332.             Case vbPRPQHigh
  333.                 Combo.ListIndex = 3
  334.             Case Else
  335.                 For i = 0 To Combo.ListCount - 1
  336.                     If Combo.ItemData(i) = PQuality Then
  337.                         Combo.ListIndex = i
  338.                         Exit For
  339.                     End If
  340.                 Next
  341.                 If i = Combo.ListCount Then
  342.                     Combo.AddItem PQuality
  343.                     Combo.ItemData(Combo.NewIndex) = PQuality
  344.                     Combo.ListIndex = Combo.NewIndex
  345.                 End If
  346.         End Select
  347.     End If
  348. End Sub
  349. Private Sub Combo_Click()
  350.     Printer.PrintQuality = Combo.ItemData(Combo.ListIndex)
  351. End Sub
  352. Private Sub Form_Load()
  353.     'RETRIEVE FORM'S LAST POSITION
  354.     With Me
  355.         .Left = GetSetting(Me.Name, "Settings", Me.Name & "MainLeft", .Left)
  356.         .Top = GetSetting(Me.Name, "Settings", Me.Name & "MainTop", .Top)
  357.     End With
  358.     'MARGINS
  359.     Text(0) = FormatNumber(GetSetting(Me.Name, "Settings", "PrintTop", 0), 2)
  360.     Text(1) = FormatNumber(GetSetting(Me.Name, "Settings", "PrintLeft", 0), 2)
  361.     Text(2) = FormatNumber(GetSetting(Me.Name, "Settings", "PrintRight", 0), 2)
  362.     Text(3) = FormatNumber(GetSetting(Me.Name, "Settings", "PrintBottom", 0), 2)
  363.     'PRINT QUALITY
  364.     Combo.ListIndex = 0
  365.     UpdateCombo FormatNumber(GetSetting(Me.Name, "Settings", "PrintQuality", vbPRPQDraft), 2)
  366. End Sub
  367. Private Sub Form_Unload(Cancel As Integer)
  368.     'SAVE FORM'S POSITION
  369.     With Me
  370.         SaveSetting Me.Name, "Settings", Me.Name & "MainLeft", .Left
  371.         SaveSetting Me.Name, "Settings", Me.Name & "MainTop", .Top
  372.     End With
  373.     Set frmPrint = Nothing
  374. End Sub
  375. Private Sub Text_GotFocus(Index As Integer)
  376.     With Text(Index)
  377.         .SelStart = 0
  378.         .SelLength = Len(.Text)
  379.     End With
  380. End Sub
  381. Private Sub Text_LostFocus(Index As Integer)
  382.     With Text(Index)
  383.         .Text = FormatNumber(.Text, 2)
  384.     End With
  385. End Sub
  386. Public Function FormatNumber(Numero As String, Decimales As Integer) As String
  387.     FormatNumber = Format(Numero, "###,###,##0." & String(Decimales, "0"))
  388. End Function
  389.